class Solution(object):
    def romanToInt(self, s):
        sum = 0
        dit = {"I": 1,
               "V": 5,
               "X": 10,
               'L': 50,
               'C': 100,
               'D': 500,
               'M': 1000
               }
        list = ["I", "V", "X", 'L', 'C', 'D', 'M']
        for i in s:
            if dit[i] < dit[list[list.index(i)+1]]:
                sum += dit[list[list.index(i)+1]]-dit[i]
            else:
                sum+dit[i]


s = input()
print(Solution().romanToInt(s))
